# 目录描述
set(PROJ_ROOT_DIR ${CMAKE_SOURCE_DIR}) # 项目根目录
set(PROJ_APP_DIR ${PROJ_ROOT_DIR}/app) # 应用源码目录
set(PROJ_BSP_DIR ${PROJ_ROOT_DIR}/bsp) # 板级支持源码目录
set(PROJ_BUILD_DIR ${PROJ_ROOT_DIR}/build) # 构建目录
set(PROJ_CMAKE_DIR ${PROJ_ROOT_DIR}/cmake) # cmake脚本目录
set(PROJ_CORE_DIR ${PROJ_ROOT_DIR}/core) # MCU驱动源码目录
set(PROJ_DRIVER_DIR ${PROJ_ROOT_DIR}/driver) # 驱动库目录
SET(PROJ_MODULE_DIR ${PROJ_ROOT_DIR}/module) # 模块源码目录
set(PROJ_TEST_DIR ${PROJ_ROOT_DIR}/test) # 测试源码目录
set(PROJ_THIRD_PART_DIR ${PROJ_ROOT_DIR}/third_parties) # 第三方件源码目录

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJ_ROOT_DIR}/bin) # 可执行文件输出目录
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJ_ROOT_DIR}/lib/dynamic) # 动态库输出目录
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJ_ROOT_DIR}/lib/static) # 静态库输出目录

# 基本配置(必需放在 project 前面)
include(${PROJ_CMAKE_DIR}/target-def.cmake) # MCU 信息设置
include(${PROJ_CMAKE_DIR}/compiler.cmake) # 编译器设置

# 项目描述
cmake_minimum_required(VERSION 3.22)
project(robot C CXX ASM)
set(VERSION_MAJOR 0 CACHE STRING "Project major version number.")
set(VERSION_MINOR 1 CACHE STRING "Project minor version number.")
set(VERSION_PATCH 0 CACHE STRING "Project patch version number.")
set(ELF_TARGET ${PROJECT_NAME}.elf) # elf文件名

# 编译模式
set(CMAKE_BUILD_TYPE Debug)
if(CMAKE_BUILD_TYPE MATCHES Debug)
  message(STATUS "Build type: Debug")
elseif(CMAKE_BUILD_TYPE MATCHES Release)
  message(STATUS "Build type: Release")
endif()

# 其它设置
set(CMAKE_EXPORT_COMPILE_COMMANDS 1) # 生成编译数据库

# 添加子目录
add_subdirectory(${PROJ_CORE_DIR})
